<?php
include "../head.php"; 
session_start(); //开启会话 
?>
<html>
	<head>
		<title>订单信息管理</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
	</head>
	<body>
		<center>
			<?php 
				include("menu.php"); //导入导航栏 
			
				//首先执行登陆验证
				if(empty($_SESSION['loginvip'])){
					//die("请先登录");
					$user= array("id"=>12,"name"=>"张三","address"=>"育荣教育园5号楼503",
							"code"=>"100086","phone"=>"1234567899");
					$_SESSION['loginvip']=$user; //此处模拟一个登陆信息
				}
				
			?>
			
						
			<h3>订单信息确认</h3>
			<form action="orderaction.php?a=add" method="post" >
			<table width="320" border="0" cellpadding="4">
				<tr>
					<td align="right">收件人：</td>
					<td><input type="text" name="linkman" readonly value="<?php echo $_POST['linkman']; ?>" style="border:0px;"/></td>
				</tr>
				<tr>
					<td align="right">地址：</td>
					<td>
						<input type="text" name="address" readonly value="<?php echo $_POST['address']; ?>" style="border:0px;"/>
					</td>
				</tr>
				<tr>
					<td align="right">邮编：</td>
					<td>
						<input type="text" name="code" readonly value="<?php echo $_POST['code']; ?>" style="border:0px;"/>
					</td>
				</tr>
				<tr>
					<td align="right">电话：</td>
					<td><input type="text" name="phone" readonly value="<?php echo $_POST['phone']; ?>" style="border:0px;"/></td>
				</tr>
				<tr>
					<td align="right">总金额：</td>
					<td>￥<?php echo $_SESSION['total']; ?>元</td>
				</tr>
				<tr>
					<td colspan="2" align="center">
						<input type="submit" value="确认提交"/>&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="button" onclick="window.history.back();" value="返回"/>
					</td>
					
				</tr>
			</table>
			
			<br/>
			
			<h3>我的购物车</h3>
			<table width="600" border="1">
				<tr>
					<th>商品名称</th>
					<th>商品图片</th>
					<th>商品单价</th>
					<th>购买数量</th>
					<th>小计</th>
				</tr>
			<?php
				$total=0; //总金额
				//遍历session购物车中的信息
				if(isset($_SESSION["shoplist"])){
					foreach($_SESSION['shoplist'] as $shop){
						echo "<tr>";
						echo "<td>{$shop['goods']}</td>";
						echo "<td><img src='./uploads/s_{$shop['picname']}'/></td>";
						echo "<td>{$shop['price']}</td>";
						echo "<td>{$shop['m']}</td>";
						echo "<td>".($shop['m']*$shop['price'])."</td>";
						echo "</tr>";
						$total+=$shop['m']*$shop['price']; //累加金额
					}
				}
				$_SESSION['total']=$total; // 将统计的总金额保存到session中
				echo "<tr>
						 <th>总计金额：</th>
						 <td colspan='4' align='right'>￥{$total}元</td>
						
						</tr>";
			?>
			</table>
			
			</form>
		</center>
	</body>
</html>